package com.code.generator.cn.controller;

import com.code.generator.cn.entity.CoderTable;
import com.code.generator.cn.service.ICoderTableService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/table")
public class TableController {

    @Autowired
    private ICoderTableService coderTableService;


    /**
     * 项目生成主页面
     * @return
     */
    @RequestMapping("/toUpdate")
    public ModelAndView getTables(HttpServletRequest request){
        ModelAndView modelAndView =new ModelAndView("/table/update");
        String id=  request.getParameter("id");
        modelAndView.addObject("obj",coderTableService.getById(id));
        return modelAndView;
    }



    /**
     * 项目生成主页面
     * @return
     */
    @RequestMapping("/update")
    public Object update(HttpServletRequest request, @ModelAttribute CoderTable coderTable){
        coderTableService.update(coderTable);
        return null;
    }

}
